/**
 * 
 */
package cn.panda.edu.teacher;

import cn.panda.edu.model.PartSection;
import cn.panda.edu.service.PartSectionService;
import cn.panda.edu.util.ResultDataUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**  
 * 类描述：  
 */
@RestController
@RequestMapping("/api/teacher/partsection")
public class TeacherPartSectionController {

	@Autowired
	private PartSectionService partSectionService;
	
	
	@ApiOperation(value = "添加小节")
	@ApiImplicitParam(name = "partSection", value = "小节类", required = false, dataType = "PartSection ")
	@RequestMapping(value = "insert", method = RequestMethod.POST)
	public  Object insert(@RequestBody PartSection partSection) {
		int status=200;
		String message=null;
		try {
			partSection.setPartAddtime(new Date());
			partSection.setPartModifyDate(new Date());
			partSectionService.insertSelective(partSection);
			status=200;
			message="添加成功!";
		} catch (Exception e) {
			status=500;
			message="添加失败!";
		}
		return ResultDataUtil.resData(status, message, null);
	}
	@ApiOperation(value = "修改小节")
	@ApiImplicitParam(name = "partSection", value = "小节类", required = false, dataType = "PartSection ")
	@RequestMapping(value = "update", method = RequestMethod.POST)
	public  Object update(@RequestBody PartSection partSection) {
		int status=200;
		String message=null;
		try {
			partSection.setPartAddtime(new Date());
			partSection.setPartModifyDate(new Date());
			partSectionService.updateByPrimaryKeySelective(partSection);
			status=200;
			message="修改成功!";
		} catch (Exception e) {
			status=500;
			message="修改失败!";
		}
		return ResultDataUtil.resData(status, message, null);
	}
}
